#!/bin/bash

echo Welcome to auto ssh no password program. HF.
echo
if [ ! -e ~/.ssh/id_rsa ]; then
	echo
	echo Och! You have no ~/.ssh/id_rsa file. No local rsa key pair.
	echo No worries. We are goin to generate them.
	echo
	ssh-keygen -t rsa
fi
echo
echo Ok.
echo
echo You need to log through ssh to given host.
echo Write your password:
echo
echo running ssh $@
cat ~/.ssh/id_rsa.pub | ssh $@ \
	"if [ -d ~/.ssh ]; then "\
	"	mkdir -p ~/.ssh ;"\
	"fi; " \
	"cat >> ~/.ssh/authorized_keys"
echo
echo Coongrats!. Youve done it!
echo
	
